/*
 * Created on 20/07/2005
 *
 */
package br.uece.tcc.flathead.jxta.utils;

import net.jxta.document.AdvertisementFactory;
import net.jxta.peergroup.PeerGroup;
import net.jxta.pipe.PipeID;
import net.jxta.protocol.PipeAdvertisement;

/**
 * @author pedro
 *
 */
public class PipeUtils {
    
//  cria um PipeID
    public static PipeID criarPipeID(PeerGroup grupo) {
        //byte[] seed = grupoAtual.getPeerID().toString().getBytes();
        return net.jxta.id.IDFactory.newPipeID(grupo.getPeerGroupID());
    }

    // cria um PipeAdvertisement
    public static PipeAdvertisement criarPipeAdvertisement(PeerGroup grupo, String nome, String tipo, String desc) {
        PipeAdvertisement pipeAdv = (PipeAdvertisement) AdvertisementFactory.newAdvertisement(PipeAdvertisement.getAdvertisementType());
        pipeAdv.setName(nome);
        pipeAdv.setType(tipo);
        pipeAdv.setDescription(desc);
        pipeAdv.setPipeID(criarPipeID(grupo));
        return pipeAdv;
    }
}
